import React from 'react'
import { useSelector,useDispatch } from 'react-redux'
import { getMovie } from '@/app/slice/movieSlice'
export default function Movie() {
  const dispatch = useDispatch()
  const movieList = useSelector((state)=>state.movie.movieList)
  const count = useSelector(state => state.count.count)
  
  return (
    <div>
      <h2>Movie</h2>
      <h2>Count的值：{count}</h2>
      <button onClick={() => {
        dispatch(getMovie())
      }}>获取最新的电影列表(发送一个ajax请求,得到新的数据,设置给redux的数据上)</button>

      <ul>
       {
        movieList.map((item)=>{
         return(
             <li key={item.tvId}>
              <h2>{item.title}</h2>
             </li>
          )
        })
       }
      </ul>
    </div>
  )
}
